package com.bwie.gddproject.index.model;

import android.util.Log;

import com.bwie.gddproject.index.model.bean.GoodCarBean;
import com.bwie.gddproject.net.NetUtil;
import com.bwie.gddproject.net.OnNetLitenner;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by peng on 2017/11/16.
 */

public class ShopCarModel implements IShopCarModel {


    @Override
    public void getGoods(final OnNetLitenner<GoodCarBean> onNetLitenner) {
        NetUtil.getResponseService().getGoodCar("71")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<GoodCarBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(GoodCarBean goodCarBean) {
                        onNetLitenner.success(goodCarBean);
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e("tag", "onError: "+e.getMessage() );
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
